<template>
  <el-card>
    <el-form :inline="true">
      <el-form-item label="一级分类">
        <el-select v-model="categoryStore.c1Id" :disabled="scene === 0 && categoryStore.c1Arr.length > 0 ? false : true" class="one_hundred_width" placeholder="请选择" clearable @change="getC2">
          <el-option v-for="c1 in categoryStore.c1Arr" :key="c1.id" :label="c1.name" :value="c1.id" />
        </el-select>
      </el-form-item>
      <el-form-item label="二级分类">
        <el-select v-model="categoryStore.c2Id" :disabled="scene === 0 && categoryStore.c2Arr.length > 0 ? false : true" class="one_hundred_width" placeholder="请选择" clearable @change="getC3">
          <el-option v-for="c2 in categoryStore.c2Arr" :key="c2.id" :label="c2.name" :value="c2.id" />
        </el-select>
      </el-form-item>
      <el-form-item label="三级分类">
        <el-select v-model="categoryStore.c3Id" :disabled="scene === 0 && categoryStore.c3Arr.length > 0 ? false : true" class="one_hundred_width" placeholder="请选择" clearable @change="getTableData">
          <el-option v-for="c3 in categoryStore.c3Arr" :key="c3.id" :label="c3.name" :value="c3.id" />
        </el-select>
      </el-form-item>
    </el-form>
  </el-card>
</template>

<script setup lang="ts">
import { onMounted } from 'vue';
import useCategoryStore from '@/store/modules/category';

let categoryStore = useCategoryStore();

defineProps(['scene']);
// 页面挂载完毕后
onMounted(() => {
  getC1();
});

//获取一级分类列表
const getC1 = () => {
  categoryStore.getC1();
};

//获取二级分类列表(一级分类的change事件)
const getC2 = () => {
  categoryStore.c2Id = '';
  categoryStore.c3Arr = [];
  categoryStore.c3Id = '';
  categoryStore.getC2();
};

//获取三级分类列表(二级分类的change事件)
const getC3 = () => {
  categoryStore.c3Id = '';
  categoryStore.getC3();
};

//获取表单数据
const getTableData = () => {};
</script>

<style lang="scss" scoped>
.one_hundred_width {
  width: 200px;
}
</style>
